I have a DXL script which exports requirements to an Excel sheet, which is then sent for acceptance by certain people in our project. For that reason I have an attribute which can take only two values, Yes or No. When exporting that attribute I apply the Validation method so that only Yes or No can be added to that Excel column. That part works like a charm, I included that function for anyone interested (it took me days to find out how to do it...). |
Re: How do I add conditional formatting to a range of Excel cells?
From the examples on the web I see on the web you need to first add the FormatCondition which will return to you the condition object, and then set the colorindex on that. So (without testing it myself) it should be something like:
selectRange (objSheet, iTop, iLeft, iBottom, iRight, objRange)
oleGet (objRange, "FormatConditions", objConditional)
if (objConditional != null) {
clear args
put (args, "Type", 1) // xlCellValue
put (args, "Operator", 3) // xlEqual
put (args, "Formula1", "Nej")
OleAutoObj objRangeCondition
// add the condition, will return the condition object
debug oleMethod (objConditional, "Add", args, objRangeCondition)
OleAutoObj objRangeConditionFont = null
// get the font property
debug oleGet (objRangeCondition, "Font", objRangeConditionFont)
// set the color index on the font
debug olePut (objRangeConditionFont, "ColorIndex", 3)
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: How do I add conditional formatting to a range of Excel cells? Mathias Mamsch - Thu Jun 14 06:17:55 EDT 2012
From the examples on the web I see on the web you need to first add the FormatCondition which will return to you the condition object, and then set the colorindex on that. So (without testing it myself) it should be something like:
selectRange (objSheet, iTop, iLeft, iBottom, iRight, objRange)
oleGet (objRange, "FormatConditions", objConditional)
if (objConditional != null) {
clear args
put (args, "Type", 1) // xlCellValue
put (args, "Operator", 3) // xlEqual
put (args, "Formula1", "Nej")
OleAutoObj objRangeCondition
// add the condition, will return the condition object
debug oleMethod (objConditional, "Add", args, objRangeCondition)
OleAutoObj objRangeConditionFont = null
// get the font property
debug oleGet (objRangeCondition, "Font", objRangeConditionFont)
// set the color index on the font
debug olePut (objRangeConditionFont, "ColorIndex", 3)
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
:-) Lennart |